﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>会员列表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="weadmin-nav">
        <span class="layui-breadcrumb" style="visibility: visible;">
            <a href="#">首页</a><span lay-separator="">/</span>
            <a href="#">基础数据设置</a><span lay-separator="">/</span>
            <a><cite>人员信息管理</cite></a>
        </span>
        <a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon" style="line-height:30px">&#x1002;</i>
        </a>
    </div>
    <div class="weadmin-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <div class="layui-row">
                    人员查询：
                    <div class="layui-inline">
                        <input type="text" id="sEmpID" placeholder="工号" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" id="sEmpName" placeholder="姓名" autocomplete="off" class="layui-input">
                    </div>
                    所属部门:
                    <div class="layui-inline">
                        <select id="RoleID" name="RoleID" class="valid"></select>
                    </div>

                </div>

            </div>
        </form>
        <button class="layui-btn" id="sreach"><i class="layui-icon">&#xe615; 查询</i></button>
        <table id="datalist" lay-filter="datalist"></table>
    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="delAll"><i class="layui-icon"></i>批量删除</button>
            <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"></i>添加</button>
            <button class="layui-btn layui-btn-sm" lay-event="addList"><i class="layui-icon"></i>批量上传</button>
        </div>
    </script>
    <script type="text/html" id="tool">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        layui.use(['table', 'jquery', 'layer', 'form'], function () {
            var table = layui.table,
                $ = layui.jquery,
                form = layui.form,
                layer = layui.layer;
            $.support.cors = true;
            $.ajaxSetup({
                cache: false,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
            })
            $.ajax({
                url: ApiUrl + "Role/Sel",
                type: 'post',
                success: function (data) {
                    if (data.StatusCode == 200) {
                        $("#RoleID").append("<option value=''></option>");
                        $(data.Data).each(function (index, item) {
                            $("#RoleID").append("<option value='" + item.RoleID + "'>" + item.RoleName + "</option>");
                        });
                        form.render();
                    }
                }
            });
            function showList() {
                var swhere = JSON.stringify({
                    UserID: $("#sEmpID").val().trim(),
                    UserName: $("#sEmpName").val().trim(),
                    RoleID: $("#RoleID").find("option:selected").val()
                });
                table.render({
                    id: "datalist",
                    elem: '#datalist',
                    url: ApiUrl + 'UserInfo/Search', //数据接口,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    where: { swhere: swhere },
                    cellMinWidth: 80,
                    toolbar: "#toolbar",
                    cols: [
                        [
                            { type: 'checkbox' },
                            { field: 'FID', title: 'FID', hide: true },
                            { field: 'UserID', title: '用户工号', width: 110 },
                            { field: 'UserSFZH', title: '身份证号', width: 190, hide: true },
                            { field: 'UserNo', title: '人员编号', width: 120, hide: true },
                            //{ field: 'UserSGZH', title: '上岗证号', width: 120},
                            { field: 'UserName', title: '姓名', width: 130 },
                            //{ field: 'DeptID', title: '部门ID',hide:true },
                            { field: 'DepName', title: '部门', width: 150 },
                            { field: 'Post', title: '职务', width: 150 },
                            { field: 'Sex', title: '性别', width: 70 },
                            { field: 'Nation', title: '民族', width: 80 },
                            //{ field: 'WorkBeforeEdu', title: '工作前文化', width: 100, hide: true },
                            //{ field: 'CurrentEdu', title: '现有文化', width: 90, hide: true },
                            //{ field: 'Politic', title: '政治面貌', width: 80, hide: true  },
                            //{
                            //    field: 'Birthday', title: '出生日期', width: 120, hide: true ,templet: function (d) {
                            //        return d.Birthday.substring(0, 10);
                            //    }
                            //},
                            //{ field: 'BeginWorkDate', title: '参加工作时间', width: 120, hide: true  },
                            //{ field: 'AppointmentDate', title: '定职时间', width: 110, hide: true  },
                            //{ field: 'InTime', title: '任现职时间', width: 120, hide: true },
                            //{ field: 'EmployeeStatus', title: '职工身份', width: 100, hide: true },
                            //{ field: 'TechnicalGrade', title: '技术等级', width: 100, hide: true },
                            //{ field: 'TechnicalPost', title: '技术职务', width: 100, hide: true },
                            //{
                            //    field: 'IsGT', title: '是否高铁', width: 100, hide: true , templet: function (d) {
                            //        return d.IsGT = null || d.IsGT==""?"否":"是";
                            //    }
                            //},
                            //{
                            //    field: 'IsBZZ', title: '是否班组长', width: 120, hide: true , templet: function (d) {
                            //        return d.IsBZZ = null || d.IsBZZ == "" ? "否" : "是";
                            //    }
                            //},
                            //{ field: 'PostStatus', title: '在岗状态', width: 100, hide: true },
                            //{
                            //    field: 'isTYZYGZ', title: '特有职业工种', width: 130, hide: true , templet: function (d) {
                            //        return d.isTYZYGZ = null || d.isTYZYGZ == "" ? "否" : "是";
                            //    }
                            //},
                            //{
                            //    field: 'IsZYXCGZ', title: '主要行车工种', width: 120, hide: true , templet: function (d) {
                            //        return d.IsZYXCGZ = null || d.IsZYXCGZ == "" ? "否" : "是";
                            //    }
                            //},
                            //{ field: 'define1', title: '预留一', width: 100, hide: true  },
                            //{ field: 'define2', title: '预留二', width: 100, hide: true  },
                            //{ field: 'define3', title: '预留三', width: 100, hide: true },
                            //{ field: 'UserID7', title: '7位乘务工号', width: 130, hide: true },
                            //{ field: 'DriverType', title: '可以驾驶机型', width: 130, hide: true },
                            //{ field: 'DriverLicense', title: '驾驶证类别', width: 120, hide: true },
                            { field: 'RoleName', title: '角色', width: 120 },
                            { field: 'Groups', title: '指导组', width: 160 },
                            { field: 'IsHaveFinger', title: '是否有指纹', width: 120 },
                            { fixed: 'right', title: '操作', align: 'center', toolbar: '#tool', width: 162 }
                        ]
                    ],
                    parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    limit:100,
                    limits:[10,30,50,100,150,200],
                    done: function (res, curr, count) {
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        if (res.code == 200) {
                            if (res.data != null) {
                                for (var i = 0; i < res.data.length; i++) {
                                    if (res.data[i].IsHaveFinger=='未录') {

                                        var tr = $('.layui-table-body tbody tr[data-index="' + i + '"]');

                                        var td = $('.layui-table-body tbody tr[data-index="' + i + '"] td[ data-field="UserID"]')
                                        td.css('background-color', 'rgb(255,0,0)');
                                        td.css('color', 'black');

                                        var td = $('.layui-table-body tbody tr[data-index="' + i + '"] td[ data-field="IsHaveFinger"]')
                                        td.css('background-color', 'rgb(255,0,0)');
                                        td.css('color', 'black');

                                    }
                                }

                            }
                        }
                    }
                });
            }
            //监听事件
            table.on('toolbar(datalist)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'delAll':
                        if (checkStatus.data.length > 0) {
                            var EIDs = "";
                            for (var i = 0; i < checkStatus.data.length; i++) {
                                EIDs += checkStatus.data[i].FID + ",";
                            }
                            EIDs = EIDs.substring(0, EIDs.length - 1);
                            $.ajax({
                                url: ApiUrl + "UserInfo/DelList",
                                type: 'get',
                                cache: false,
                                data: { delidlist: EIDs },
                                success: function (data) {
                                    if (data.StatusCode == 200 && data.Count != 0) {
                                        layer.alert(data.Info, { icon: 6 }, function (index) {
                                            layer.close(index);
                                            location.reload();
                                        })
                                    }
                                    else if (data.StatusCode == 403) {
                                        top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                                            top.location.href = "http://" + top.location.host + "/login.html";
                                        })
                                    }
                                    else {
                                        layer.msg(data.Info);
                                    }
                                }
                            });
                        }
                        else {
                            layer.msg("未找到勾选项！");
                        }
                        break;
                    case 'add':
                        var add = layer.open({
                            type: 2,
                            title: "人员信息添加",
                            area: ['700px', '450px'],
                            fixed: false, //不固定
                            maxmin: true,
                            content: './employee_add.html',
                            end: function () {
                                location.reload();
                            }
                        });
                        layer.full(add);
                        break;
                    case 'addList':
                        var upload = layer.open({
                            type: 2,
                            title: "人员信息上传",
                            area: ['500px', '300px'],
                            fixed: false, //不固定
                            maxmin: true,
                            content: './employee_upload.html',
                            end: function () {
                                location.reload();
                            }
                        });
                        break;
                };
            });
            //监听工具条
            table.on('tool(datalist)', function (obj) {
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                //var tr = obj.tr; //获得当前行 tr 的DOM对象
                if (layEvent === 'detail') { //查看
                    var detail = layer.open({
                        type: 2,
                        title: "人员信息详情",
                        area: ['700px', '450px'],
                        fixed: false, //不固定
                        maxmin: true,
                        content: './employee_detail1.html?FID=' + data.FID,
                    });
                    layer.full(detail);
                } else if (layEvent === 'del') { //删除
                    layer.confirm('确定要删除吗？', function (index) {
                        //向服务端发送删除指令
                        $.ajax({
                            url: ApiUrl + "UserInfo/DelList",
                            type: 'get',
                            data: { delidlist: data.FID },
                            success: function (data) {
                                if (data.StatusCode == 200 && data.Count != 0) {
                                    layer.alert(data.Info, { icon: 6 }, function (index) {
                                        layer.close(index);
                                        obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
                                    })
                                }
                                else if (data.StatusCode == 403) {
                                    top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                                        top.location.href = "http://" + top.location.host + "/login.html";
                                    })
                                }
                                else {
                                    layer.msg(data.Info);
                                }
                            }
                        });
                    });
                } else if (layEvent === 'edit') { //编辑
                    var edit = layer.open({
                        type: 2,
                        title: "人员信息编辑",
                        area: ['700px', '450px'],
                        fixed: false, //不固定
                        maxmin: true,
                        content: './employee_editNew.html?FID=' + data.FID,
                        end: function () {
                            location.reload();
                        }
                    });
                    layer.full(edit);
                }
            });
            $(function () {
                showList();
                $("#sreach").click(function () {
                    showList();
                })
            })
        });
    </script>
</body>
</html>